To the best of my knowledge for some peculiar reason, Microsoft has never seen fit to provide us a way to produce a list to COPY/PASTE or printout all the files in a directory. Fortunately LB does have a very simple way. This program is based on DIRS.BAS kindly provided with LB. You might like to compare the section following [dirs] below with this program.
Note the use of DefaultDir$ = left$(DefaultDir$,2) + "\" in the code under [dirs] which sets the filedialog to the Root Directory. The user is invited to either select a sample file for a list to be created of the same .EXT. or enter ‘ALL’ for a list of every file. You will notice the list of files uses an invisible TEXTEDITOR to store the data and then paste it back to the Text Window. This complicated routine was provided by another in the LB egroup some time back. Using a Text Editor eliminates the screen flicker associated with Text Windows.
If you do not opt for the File Printout after highlighting text, then the [scdump] in the [view] menu, provides a way of obtaining a formatted screen printout of the display. A suitable Print Font, such as Courier, should be selected for a neatly formatted display. LB version 4 now has a nice new feature, PrinterFont$, whereby we can select the printer font. This, however, does not prevent the program from working with version 3.03. In the case of version 3.03, the PrinterFont$ is merely ignored.
Gordon Sweet
Gordon's Webpage site for LB CODE has been moved to
' Long Filename Lister LB Ver. 3 & 4 ONLY
nomainwin
dim dir$(10,3) : dim dat$(5000)
f$ = "None" : max = 0 : total =0
ux = 1 : uy = 1
if DisplayWidth > 1000 then ux = 120 : uy = 90
[opts]
UpperLeftX = ux : UpperLeftY = uy
WindowWidth = 800 : WindowHeight = 580
button #1, "Select Files", [list], LL 90, 100
button #1, "Save Listing", [save], LL 220, 100
button #1, "View Listing", [view], LL 350, 100
button #1, "Notepad View", [npad], LL 480, 100
button #1, "*** QUIT ***", [quit], LL 610, 100
open "Long Filenames" for graphics_nsb as #1
[reset]
#1 "trapclose [quit]; font arial 24 bold"
#1 "fill lightgray; backcolor lightgray"
#1 "color black; place 220 100"
#1 "\LONG FILENAME LISTER"
#1 "font arial 10; place 300 140"
#1 "\Gordon Sweet Ver. 2.5 December 2003"
#1 "font arial 14 bold; color darkblue; place 200 200 1"
#1 "\This program can produce a TXT file with a list"
#1 "\of Long Filenames of any chosen Directory. By"
#1 "\selecting any file by .EXT the list will then only"
#1 "\show those files with that Extension.\"
#1 "font fixedsys"
#1 "\";total;" Records held in Current File:- ";f$
#1 "flush" : playwave "ping.wav" : win1 = 1 : wait
[dirs]
DefaultDir$ = left$(DefaultDir$,2) + "\"
redim dir$(10,3) : redim dat$(5000) : total = 0
filedialog "Select any file by .EXT or enter ALL ","*.*",File$
if File$ = "" then close #1 : goto [opts]
confirm "Include Size & Date?"; ful$
full = 0 : if ful$="yes" then full = 1
File$ = upper$(File$) ' Simplifies Identification
sFile$ = noPath$(File$)
plen = len(File$)-len(sFile$)
path$ = left$(File$,plen)
ext$ = "*."+right$(File$,3) ' Select by .EXT or All files
if ext$ = "*.ALL" then ext$ = "*.*"
files path$, ext$, dir$()
maxlen = 0
qtyFiles = val(dir$(0, 0))
qtySubDirs = val(dir$(0, 1))
if qtyFiles = 0 and qtySubDirs = 0 then
notice "EMPTY DIRECTORY!!"
goto [quit]
end if
if qtyFiles = 0 then [subs]
'reformat the file information
for x = 1 to qtyFiles
if full = 0 then [nfull]
dat$(x)=left$(dir$(x, 0) + " ", 13) + " "+ dir$(x, 1)+ " "+ dir$(x, 2)
goto [done]
[nfull]
dir$(x, 1) = right$(" " + dir$(x, 1), 9)
dat$(x) = dir$(x, 0)
[done]
tlen = len(dat$(x))
if maxlen < tlen then maxlen = tlen
next x
sort dat$(), qtyFiles, 1
[subs]
if qtySubDirs = 0 then goto [mis]
for x = qtyFiles + 1 to qtyFiles + qtySubDirs
dat$(x) = dir$(x, 1) + "*"
tlen = len(dat$(x))
if maxlen < tlen then maxlen = tlen
next x
[mis]
maxlen = maxlen + 2
if store = 1 then goto [save2] else return
[list]
redim dir$(10,3) : redim dat$(5000)
gosub [dirs] : total = x -1
[view]
if total = 0 then notice "NOTHING SELECTED":wait
close #1 : win1 = 0
texteditor #v.tb 20,20,0,0 'this is invisible
menu #v, "&OPTIONS", "&New List", [new],"&Printout",[scdump],|,"&Quit",[quit]
tl$ = "File Listing - Options/PrintDump with Courier produces best Printout"
open tl$ for text_fs as #v
#v "!trapclose [new]" : #v "!font fixedsys"
total$ = "Total files ";qtyFiles
max = total + 5
lin = 1 : col = 1
#v.tb total$
gosub [tbox]
ncols = int(84/maxlen) : lencol = max/ncols + 1
lin = 2 : col = 1
for x = total to 1 step -1
#v.tb dat$(x);
gosub [tbox] : lin = lin + 1
if lin > lencol then col = col + maxlen : lin = 2
next x
#v "!lines"
input #v, lpos 'last line for print
#v "!origin 1 1"; ' move scroll bars back
winv = 1 : wait
[new]
close #v : winv = 0 : goto [opts]
[save]
if total = 0 then notice "No listing!" : wait
filedialog "Save as a TXT file","*.txt",f$
if f$ = "" then wait
count = 1 ' for total$
OPEN f$ FOR OUTPUT AS #s
print #s, total$
for n = qtyFiles to 1 step -1
print #s, dat$(n) : count = count + 1
next n : close #s
notice "Saved as "; f$
goto [reset]
[npad]
close #1 : win1 = 0
filedialog "Any TXT File","*.txt",n$
run$ = "notepad.exe " + n$
run run$, showmaximized : goto [opts]
[tbox]
print #v.tb, "!selectall";
print #v.tb, "!cut";
#v "!select ";col;" ";lin;
#v "!paste";
return
[scdump]
'The Font for PrinterFont$ only reconised by Ver. 4
PrinterFont$ = "courier_new 10 bold"
for row = 1 to lpos
for colm = 1 to 80
#v "!select ";colm;" ";row;" ";
#v "!setfocus";
#v "!line ";row;" txt$";
char$=mid$(txt$,colm,1)
lprint char$;
next colm : lprint : next row
printerdialog : dump
notice "Data passed to printer"
wait
[quit]
if winv = 1 then close #v
if win1 = 1 then close #1
end
function noPath$(t$)
while instr(t$, "\")
t$ = mid$(t$, 2)
wend
noPath$ = t$
end function